package com.study.designpattern.iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IteratorPattern{
	
	private List<String> list = new ArrayList<String>();
	
	public void add(String name){
		list.add(name);
	}
	
	public Iterator<String> iterator(){
		return list.iterator();
	}
	
	public static void main(String args[]){
		
		IteratorPattern itp = new IteratorPattern();
		itp.add("aaaaa");
		itp.add("bbbbb");
		itp.add("ccccc");
		
		Iterator<String> it = itp.iterator();
		while(it.hasNext()){
			String element = it.next();
			System.out.println(element);
		}
		
	}

}
